package com.dubbo.goods.rest;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import com.dubbo.goods.domain.GoodsDTO;
import com.dubbo.goods.service.GoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * @author goods
 * @create 2017-11-16 16:12
 */
@Path("goods")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({ContentType.APPLICATION_JSON_UTF_8})
@Service("goodsRestService")
public class GoodsRestServiceImpl implements GoodsRestService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private GoodsService goodsService;

    @GET
    @Path("")
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    @Override
    public GoodsDTO findAllGoods() {
        logger.info("restful 提供获取数据的接口");

        return goodsService.findAllGoods();
    }
}
